// SettingsDialog.cpp : implementation file
//

#include "stdafx.h"
#include "SettingsDialog.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CSettingsDialog dialog


CSettingsDialog::CSettingsDialog(CWnd* pParent /*=NULL*/)
	: CDialog(CSettingsDialog::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSettingsDialog)
	m_filename = _T("");
	m_ischain = FALSE;
	m_isstretch = FALSE;
	m_istile = FALSE;
	//}}AFX_DATA_INIT
}


void CSettingsDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSettingsDialog)
	DDX_Text(pDX, IDC_EDIT_FILENAME, m_filename);
	DDX_Check(pDX, IDC_CHECK_CHAIN, m_ischain);
	DDX_Check(pDX, IDC_CHECK_STRETCH, m_isstretch);
	DDX_Check(pDX, IDC_CHECK_TILE, m_istile);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSettingsDialog, CDialog)
	//{{AFX_MSG_MAP(CSettingsDialog)
	ON_BN_CLICKED(IDC_BUTTON_BROWSE, OnButtonBrowse)
	ON_BN_CLICKED(IDC_CHECK_TILE, OnCheckTile)
	ON_BN_CLICKED(IDC_CHECK_STRETCH, OnCheckStretch)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSettingsDialog message handlers

void CSettingsDialog::OnButtonBrowse() 
{
	CString S;
	S.LoadString(IDS_PICFILES);
	CFileDialog dlg (TRUE, NULL, NULL, 0,S, this);
	if (dlg.DoModal() == IDOK) S=dlg.GetPathName();
	if (S!="") GetDlgItem(IDC_EDIT_FILENAME)->SetWindowText(S);
	
}

void CSettingsDialog::OnCheckTile() 
{
	UpdateData(TRUE);
	GetDlgItem(IDC_CHECK_STRETCH)->EnableWindow(!m_istile);
	GetDlgItem(IDC_CHECK_CHAIN)->EnableWindow(!m_istile);
}

BOOL CSettingsDialog::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	
	OnCheckTile() ;

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CSettingsDialog::OnCheckStretch() 
{
	UpdateData(TRUE);

	GetDlgItem(IDC_CHECK_TILE)->EnableWindow(m_isstretch);
	GetDlgItem(IDC_CHECK_CHAIN)->EnableWindow(m_isstretch);
}
